﻿@model NewsItemModel
@using Giant.Web.Models.News;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
    //meta
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);
    //page class
    Html.AppendPageCssClassParts("html-news-item-page");
}
<div class="page news-item-page">
    <div class="page-title">
        <h1>@Model.Title</h1>
    </div>
    <div class="page-body">
        <div class="news-date">
            @Model.CreatedOn.ToString("D")
        </div>
        @Html.Widget("newsitem_page_before_body", Model.Id)
        <div class="news-body">
            @Html.Raw(Model.Full)
        </div>
        @Html.Widget("newsitem_page_before_comments", Model.Id)
        @if (Model.AllowComments)
        {
            <div class="fieldset new-comment" id="comments">
                <div class="title">
                    <strong>@T("News.Comments.LeaveYourComment")</strong>
                </div>
                <div class="notifications">
                    @{
                        var validationSummary = Html.ValidationSummary(true);
                    }
                    @if (!MvcHtmlString.IsNullOrEmpty(validationSummary))
                    {
                        <div class="message-error">@validationSummary</div>
                    }
                    @{
                        var result = TempData["app.news.addcomment.result"] as string;
                    }
                    @if (!String.IsNullOrEmpty(result))
                    {
                        <div class="result">@result</div>
                    }
                </div>
                @using (Html.BeginForm())
                {
                    @Html.AntiForgeryToken()
                    <div class="form-fields">
                        <div class="inputs">
                            @Html.LabelFor(model => model.AddNewComment.CommentTitle, new { }, ":")
                            @Html.TextBoxFor(model => model.AddNewComment.CommentTitle, new { @class = "enter-comment-title" })
                            @Html.ValidationMessageFor(model => model.AddNewComment.CommentTitle)
                        </div>
                        <div class="inputs">
                            @Html.LabelFor(model => model.AddNewComment.CommentText, new { }, ":")
                            @Html.TextAreaFor(model => model.AddNewComment.CommentText, new { @class = "enter-comment-text" })
                            @Html.ValidationMessageFor(model => model.AddNewComment.CommentText)
                        </div>
                        @if (Model.AddNewComment.DisplayCaptcha)
                        {
                            <div class="captcha-box">
                                @Html.Raw(Html.GenerateCaptcha())
                            </div>
                        }
                    </div>
                    <div class="buttons">
                        <input type="submit" name="add-comment" class="button-1 news-item-add-comment-button" value="@T("News.Comments.SubmitButton")" />
                    </div>
                }
            </div>
            if (Model.Comments.Count > 0)
            {
                <div class="comment-list">
                    <div class="title">
                        <strong>@T("News.Comments")</strong>
                    </div>
                    <div class="comments">
                        @foreach (var comment in Model.Comments)
                        {
                            <div class="comment news-comment">
                                <div class="comment-info">
                                    <div class="user-info">
                                        @if (comment.AllowViewingProfiles)
                                        {
                                            <a href="@Url.RouteUrl("UserProfile", new { id = comment.UserId })" class="username">@(comment.UserName)</a>
                                        }
                                        else
                                        {
                                            <span class="username">@(comment.UserName)</span>
                                        }

                                        @if (!String.IsNullOrEmpty(comment.UserAvatarUrl))
                                        {
                                            <div class="avatar">
                                                @if (comment.AllowViewingProfiles)
                                                {
                                                    <a href="@Url.RouteUrl("UserProfile", new { id = comment.UserId })" class="avatar-img-link">
                                                        <img src="@(comment.UserAvatarUrl)" class="avatar-img"  alt="avatar" />
                                                    </a>
                                                }
                                                else
                                                {
                                                    <img src="@(comment.UserAvatarUrl)" class="avatar-img" alt="avatar" />
                                                }
                                            </div>
                                        }
                                    </div>
                                </div>
                                <div class="comment-content">
                                    <div class="comment-time">
                                        <label>@T("News.Comments.CreatedOn"):</label>
                                        <span class="stat-value">@comment.CreatedOn.ToString("g")</span>
                                    </div>
                                    <div class="comment-title">
                                        <strong class="comment-text">@comment.CommentTitle</strong>
                                    </div>
                                    <div class="comment-body">
                                        <p class="comment-text">@Html.Raw(Giant.Core.Html.HtmlHelper.FormatText(comment.CommentText, false, true, false, false, false, false))</p>
                                    </div>
                                </div>
                                @Html.Widget("newsitem_page_inside_comment", comment.Id)
                            </div>
                        }
                    </div>
                </div>
            }
        }
        @Html.Widget("newsitem_page_after_comments", Model.Id)
    </div>
</div>
